/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * MainPanel.java
 *
 * Created on 22-05-2009, 20:05:54
 */
package VIEW;

import CONTROLLER.Controller;

/**
 *
 * @author Irene
 */
public class MainPanel extends javax.swing.JPanel {

    private Controller ctrl;
    private Link_panel linkPanel;
    private Password_panel passPanel;
    private Contact_panel contactPanel;
    private Journal_panel journalPanel;
    private Shopping_panel shoppingPanel;
    private Dietplan_panel dietplanPanel;
    private Event_panel eventPanel;
    private Research_panel researchPanel;
    private Dayplan_panel dayplanPanel;

    /** Creates new form MainPanel
     * @param ctrl
     * @param linkPanel
     * @param passPanel
     * @param contactPanel
     * @param journalPanel
     * @param shoppingPanel
     * @param dietplanPanel
     */
    public MainPanel(Controller ctrl, Link_panel linkPanel, Password_panel passPanel, Contact_panel contactPanel, Journal_panel journalPanel, Shopping_panel shoppingPanel, Dietplan_panel dietplanPanel, Event_panel eventPanel, Research_panel researchPanel, Dayplan_panel dayplanPanel) {
        initComponents();
        this.ctrl = ctrl;
        this.linkPanel = linkPanel;
        this.passPanel = passPanel;
        this.contactPanel = contactPanel;
        this.journalPanel = journalPanel;
        this.shoppingPanel = shoppingPanel;
        this.dietplanPanel = dietplanPanel;
        this.eventPanel = eventPanel;
        this.researchPanel = researchPanel;
        this.dayplanPanel = dayplanPanel;


        tabPane.addTab("Events", eventPanel);
        tabPane.addTab("Dietplan", dietplanPanel);
        tabPane.addTab("Shopping", shoppingPanel);
        tabPane.addTab("Journal", journalPanel);
        tabPane.addTab("Contacts", contactPanel);
        tabPane.addTab("Passwords", passPanel);
        tabPane.addTab("Links", linkPanel);
        tabPane.addTab("Research", researchPanel);
        tabPane.addTab("Dayplan", dayplanPanel);




    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        tabPane = new javax.swing.JTabbedPane();
        jLabel1 = new javax.swing.JLabel();
        SAVEpim = new javax.swing.JButton();
        loadButton = new javax.swing.JButton();

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 14));
        jLabel1.setText("Menu");

        SAVEpim.setText("save");
        SAVEpim.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SAVEpimActionPerformed(evt);
            }
        });

        loadButton.setText("Load");
        loadButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                loadButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addContainerGap(1038, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(612, Short.MAX_VALUE)
                .addComponent(loadButton)
                .addGap(64, 64, 64)
                .addComponent(SAVEpim)
                .addGap(300, 300, 300))
            .addGroup(layout.createSequentialGroup()
                .addComponent(tabPane, javax.swing.GroupLayout.PREFERRED_SIZE, 1067, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(19, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jLabel1)
                .addGap(15, 15, 15)
                .addComponent(tabPane, javax.swing.GroupLayout.PREFERRED_SIZE, 630, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(42, 42, 42)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(SAVEpim)
                    .addComponent(loadButton))
                .addContainerGap(66, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void SAVEpimActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SAVEpimActionPerformed
        ctrl.saveJournals();
        ctrl.saveContacts();
        ctrl.saveDietplan();
        ctrl.saveEvent();
        ctrl.saveLink();
        ctrl.savePassword();
        ctrl.saveResearch();
        ctrl.saveShopping();
}//GEN-LAST:event_SAVEpimActionPerformed

    private void loadButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_loadButtonActionPerformed
        ctrl.loadJournals();
        journalPanel.updateJournalList();
        ctrl.loadContacts();
        contactPanel.updateContactList();
        ctrl.loadDietplan();
        dietplanPanel.updateDietplan();
        ctrl.loadEvent();
        eventPanel.updateEventList();
        ctrl.loadLink();
        linkPanel.updateLinks();
        ctrl.loadPassword();
        passPanel.updatePasswords();
        ctrl.loadResearch();
        researchPanel.updateResearch();
        ctrl.loadShopping();
        shoppingPanel.updateShopping();
    }//GEN-LAST:event_loadButtonActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton SAVEpim;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JButton loadButton;
    private javax.swing.JTabbedPane tabPane;
    // End of variables declaration//GEN-END:variables
}
